#include <iostream>
#include <vector>

using namespace std;
class Solution
{
public:
    vector<int> selfDividingNumbers(int left, int right)
    {
        auto isDividing = [](int num) -> bool
        {
            int temp = num;
            while (num)
            {
                 int mod=num % 10;
                if ( mod==0 || 0 != temp %mod)
                {
                    return false;
                }
                num /= 10;
            }
            return true;
        };
        vector<int> ans;
        while (left <= right)
        {
            if (isDividing(left))
            {
                ans.push_back(left);
            }
            left++;
        }
        return ans;
    }
};
int main()
{
    Solution s;
    vector<int> ans = s.selfDividingNumbers(1, 22);
    for (int a : ans)
    {
        cout << a << " ";
    }
    cout << endl;
    system("pause");
    return 0;
}
